@dxos/react-ui-editor 0.8.1-staging.5be625a → 0.8.1-staging.97aedb1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/lib/browser/index.mjs +276 -140
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +310 -178
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +276 -140
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/InputMode.stories.d.ts +2 -2
  11. package/dist/types/src/TextEditor.stories.d.ts +5 -40
  12. package/dist/types/src/TextEditor.stories.d.ts.map +1 -1
  13. package/dist/types/src/components/EditorToolbar/EditorToolbar.d.ts.map +1 -1
  14. package/dist/types/src/defaults.d.ts +2 -0
  15. package/dist/types/src/defaults.d.ts.map +1 -1
  16. package/dist/types/src/extensions/command/command.d.ts +4 -2
  17. package/dist/types/src/extensions/command/command.d.ts.map +1 -1
  18. package/dist/types/src/extensions/command/hint.d.ts.map +1 -1
  19. package/dist/types/src/extensions/command/menu.d.ts +12 -0
  20. package/dist/types/src/extensions/command/menu.d.ts.map +1 -0
  21. package/dist/types/src/extensions/command/preview.d.ts +12 -0
  22. package/dist/types/src/extensions/command/preview.d.ts.map +1 -0
  23. package/dist/types/src/extensions/command/state.d.ts.map +1 -1
  24. package/dist/types/src/extensions/comments.d.ts +3 -3
  25. package/dist/types/src/extensions/comments.d.ts.map +1 -1
  26. package/dist/types/src/extensions/factories.d.ts +1 -1
  27. package/dist/types/src/extensions/factories.d.ts.map +1 -1
  28. package/dist/types/src/{styles/stack-item-content-class-names.d.ts → fragments.d.ts} +1 -1
  29. package/dist/types/src/fragments.d.ts.map +1 -0
  30. package/dist/types/src/index.d.ts +0 -1
  31. package/dist/types/src/index.d.ts.map +1 -1
  32. package/dist/types/src/styles/theme.d.ts.map +1 -1
  33. package/package.json +27 -27
  34. package/src/InputMode.stories.tsx +4 -4
  35. package/src/TextEditor.stories.tsx +173 -59
  36. package/src/components/EditorToolbar/EditorToolbar.tsx +4 -5
  37. package/src/defaults.ts +12 -0
  38. package/src/extensions/command/command.ts +21 -2
  39. package/src/extensions/command/hint.ts +3 -0
  40. package/src/extensions/command/menu.ts +100 -0
  41. package/src/extensions/command/preview.ts +79 -0
  42. package/src/extensions/command/state.ts +9 -4
  43. package/src/extensions/comments.ts +6 -10
  44. package/src/extensions/factories.ts +3 -3
  45. package/src/{styles/stack-item-content-class-names.ts → fragments.ts} +3 -1
  46. package/src/index.ts +0 -4
  47. package/src/styles/theme.ts +5 -1
  48. package/dist/types/src/styles/stack-item-content-class-names.d.ts.map +0 -1
@@ -35,14 +35,14 @@ var translations_default = [
35
35
 
36
36
  // packages/ui/react-ui-editor/src/index.ts
37
37
  import { EditorState as EditorState3 } from "@codemirror/state";
38
- import { EditorView as EditorView21, keymap as keymap11 } from "@codemirror/view";
38
+ import { EditorView as EditorView22, keymap as keymap11 } from "@codemirror/view";
39
39
  import { tags as tags2 } from "@lezer/highlight";
40
40
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
41
41
 
42
42
  // packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
43
43
  import React, { useCallback } from "react";
44
44
  import { ElevationProvider } from "@dxos/react-ui";
45
- import { ToolbarMenu, MenuProvider, useMenuActions, createGapSeparator } from "@dxos/react-ui-menu";
45
+ import { MenuProvider, ToolbarMenu, createGapSeparator, useMenuActions } from "@dxos/react-ui-menu";
46
46
  import { textBlockWidth } from "@dxos/react-ui-theme";
47
47
 
48
48
  // packages/ui/react-ui-editor/src/components/EditorToolbar/util.ts
@@ -311,9 +311,8 @@ var createViewMode = (state) => {
311
311
  };
312
312
  };
313
313
 
314
- // packages/ui/react-ui-editor/src/styles/stack-item-content-class-names.ts
314
+ // packages/ui/react-ui-editor/src/fragments.ts
315
315
  import { mx } from "@dxos/react-ui-theme";
316
- var stackItemContentEditorClassNames = (role) => mx("dx-focus-ring-inset data-[toolbar=disabled]:pbs-2 attention-surface", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
317
316
  var stackItemContentToolbarClassNames = (role) => mx("attention-surface is-full border-be !border-separator", role === "section" && "sticky block-start-0 z-[1] -mbe-px min-is-0");
318
317
 
319
318
  // packages/ui/react-ui-editor/src/components/EditorToolbar/EditorToolbar.tsx
@@ -465,6 +464,10 @@ var defaultTheme = {
465
464
  background: "transparent"
466
465
  },
467
466
  ".cm-gutter": {},
467
+ ".cm-gutter.cm-lineNumbers": {
468
+ paddingRight: "4px",
469
+ borderRight: "1px solid var(--dx-separator)"
470
+ },
468
471
  ".cm-gutter.cm-lineNumbers .cm-gutterElement": {
469
472
  minWidth: "40px",
470
473
  alignContent: "center"
@@ -474,7 +477,7 @@ var defaultTheme = {
474
477
  */
475
478
  ".cm-gutterElement": {
476
479
  alignItems: "center",
477
- fontSize: "16px"
480
+ fontSize: "12px"
478
481
  },
479
482
  /**
480
483
  * Line.
@@ -649,6 +652,8 @@ var editorMonospace = EditorView.theme({
649
652
  }
650
653
  });
651
654
  var editorWithToolbarLayout = "grid grid-cols-1 grid-rows-[min-content_1fr] data-[toolbar=disabled]:grid-rows-[1fr] justify-center content-start overflow-hidden";
655
+ var stackItemContentEditorClassNames = (role) => mx3("attention-surface dx-focus-ring-inset data-[toolbar=disabled]:pbs-2", role === "section" ? "[&_.cm-scroller]:overflow-hidden [&_.cm-scroller]:min-bs-24" : "min-bs-0");
656
+ var stackItemContentToolbarClassNames2 = (role) => mx3("attention-surface is-full border-be !border-separator", role === "section" && "sticky block-start-0 z-[1] -mbe-px min-is-0");
652
657
 
653
658
  // packages/ui/react-ui-editor/src/extensions/annotations.ts
654
659
  import { StateField } from "@codemirror/state";
@@ -1853,7 +1858,7 @@ var random = (min, max) => {
1853
1858
  };
1854
1859
 
1855
1860
  // packages/ui/react-ui-editor/src/extensions/command/command.ts
1856
- import { EditorView as EditorView7, keymap as keymap3 } from "@codemirror/view";
1861
+ import { EditorView as EditorView8, keymap as keymap3 } from "@codemirror/view";
1857
1862
 
1858
1863
  // packages/ui/react-ui-editor/src/extensions/command/hint.ts
1859
1864
  import { RangeSetBuilder } from "@codemirror/state";
@@ -1889,18 +1894,19 @@ var commandState = StateField3.define({
1889
1894
  const widthWithoutPadding = parent.clientWidth - parseFloat(paddingLeft) - parseFloat(paddingRight);
1890
1895
  dom.style.width = `${widthWithoutPadding}px`;
1891
1896
  }
1892
- options.onRender(dom, (action) => {
1897
+ options.onRenderDialog(dom, (action) => {
1893
1898
  view2.dispatch({
1894
1899
  effects: closeEffect.of(null)
1895
1900
  });
1896
1901
  if (action?.insert?.length) {
1902
+ const text = action.insert + "\n";
1897
1903
  view2.dispatch({
1898
1904
  changes: {
1899
1905
  from: pos,
1900
- insert: action.insert
1906
+ insert: text
1901
1907
  },
1902
1908
  selection: {
1903
- anchor: pos + action.insert.length
1909
+ anchor: pos + text.length
1904
1910
  }
1905
1911
  });
1906
1912
  }
@@ -2027,23 +2033,156 @@ var hintViewPlugin = ({ onHint }) => ViewPlugin3.fromClass(class {
2027
2033
  ]
2028
2034
  });
2029
2035
 
2036
+ // packages/ui/react-ui-editor/src/extensions/command/menu.ts
2037
+ import { ViewPlugin as ViewPlugin4 } from "@codemirror/view";
2038
+ var floatingMenu = (options) => ViewPlugin4.fromClass(class {
2039
+ constructor(view) {
2040
+ this.rafId = null;
2041
+ this.view = view;
2042
+ const container = view.scrollDOM;
2043
+ if (getComputedStyle(container).position === "static") {
2044
+ container.style.position = "relative";
2045
+ }
2046
+ this.button = document.createElement("div");
2047
+ this.button.style.position = "absolute";
2048
+ this.button.style.zIndex = "10";
2049
+ this.button.style.display = "none";
2050
+ options.onRenderMenu(this.button, () => {
2051
+ openCommand(view);
2052
+ });
2053
+ container.appendChild(this.button);
2054
+ container.addEventListener("scroll", this.scheduleUpdate);
2055
+ this.scheduleUpdate();
2056
+ }
2057
+ update(update2) {
2058
+ if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(openEffect)))) {
2059
+ this.button.style.display = "none";
2060
+ } else if (update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(closeEffect)))) {
2061
+ this.button.style.display = "block";
2062
+ } else if (update2.selectionSet || update2.viewportChanged || update2.docChanged || update2.geometryChanged) {
2063
+ this.scheduleUpdate();
2064
+ }
2065
+ }
2066
+ scheduleUpdate() {
2067
+ if (this.rafId != null) {
2068
+ cancelAnimationFrame(this.rafId);
2069
+ }
2070
+ this.rafId = requestAnimationFrame(() => this.updateButtonPosition());
2071
+ }
2072
+ updateButtonPosition() {
2073
+ const pos = this.view.state.selection.main.head;
2074
+ const lineBlock = this.view.lineBlockAt(pos);
2075
+ const domInfo = this.view.domAtPos(lineBlock.from);
2076
+ let node = domInfo.node;
2077
+ while (node && !(node instanceof HTMLElement)) {
2078
+ node = node.parentNode;
2079
+ }
2080
+ if (!node) {
2081
+ this.button.style.display = "none";
2082
+ return;
2083
+ }
2084
+ const lineRect = node.getBoundingClientRect();
2085
+ const containerRect = this.view.scrollDOM.getBoundingClientRect();
2086
+ const offsetTop = lineRect.top - containerRect.top + this.view.scrollDOM.scrollTop;
2087
+ const offsetLeft = this.view.scrollDOM.clientWidth + this.view.scrollDOM.scrollLeft - lineRect.x;
2088
+ this.button.style.top = `${offsetTop}px`;
2089
+ this.button.style.left = `${offsetLeft}px`;
2090
+ this.button.style.display = "block";
2091
+ }
2092
+ destroy() {
2093
+ this.button.remove();
2094
+ if (this.rafId != null) {
2095
+ cancelAnimationFrame(this.rafId);
2096
+ }
2097
+ }
2098
+ });
2099
+
2100
+ // packages/ui/react-ui-editor/src/extensions/command/preview.ts
2101
+ import { syntaxTree } from "@codemirror/language";
2102
+ import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField4 } from "@codemirror/state";
2103
+ import { Decoration as Decoration4, EditorView as EditorView7, WidgetType as WidgetType3 } from "@codemirror/view";
2104
+ var preview = (options) => {
2105
+ return [
2106
+ StateField4.define({
2107
+ create: (state) => buildDecorations(state, options),
2108
+ update: (_, tr) => buildDecorations(tr.state, options),
2109
+ // TODO(burdon): Make atomic.
2110
+ provide: (field) => EditorView7.decorations.from(field)
2111
+ })
2112
+ ];
2113
+ };
2114
+ var buildDecorations = (state, options) => {
2115
+ const builder = new RangeSetBuilder2();
2116
+ syntaxTree(state).iterate({
2117
+ enter: (node) => {
2118
+ if (node.name === "Link") {
2119
+ const urlNode = node.node.getChild("URL");
2120
+ if (urlNode) {
2121
+ const text = state.sliceDoc(node.from + 1, urlNode.from - 2);
2122
+ const url = state.sliceDoc(urlNode.from, urlNode.to);
2123
+ builder.add(node.from, node.to, Decoration4.replace({
2124
+ block: true,
2125
+ widget: new PreviewWidget(options.onRenderPreview, url, text)
2126
+ }));
2127
+ }
2128
+ }
2129
+ }
2130
+ });
2131
+ return builder.finish();
2132
+ };
2133
+ var PreviewWidget = class extends WidgetType3 {
2134
+ constructor(_onRenderPreview, _url, _text) {
2135
+ super();
2136
+ this._onRenderPreview = _onRenderPreview;
2137
+ this._url = _url;
2138
+ this._text = _text;
2139
+ }
2140
+ eq(other) {
2141
+ return this._url === other._url;
2142
+ }
2143
+ toDOM(view) {
2144
+ const root = document.createElement("div");
2145
+ root.classList.add("cm-preview");
2146
+ this._onRenderPreview(root, {
2147
+ url: this._url,
2148
+ text: this._text
2149
+ });
2150
+ return root;
2151
+ }
2152
+ };
2153
+
2030
2154
  // packages/ui/react-ui-editor/src/extensions/command/command.ts
2031
2155
  var command = (options) => {
2032
2156
  return [
2033
2157
  commandConfig.of(options),
2034
2158
  commandState,
2035
2159
  keymap3.of(commandKeyBindings),
2160
+ preview(options),
2161
+ floatingMenu(options),
2036
2162
  hintViewPlugin(options),
2037
- EditorView7.focusChangeEffect.of((_, focusing) => {
2163
+ EditorView8.focusChangeEffect.of((_, focusing) => {
2038
2164
  return focusing ? closeEffect.of(null) : null;
2165
+ }),
2166
+ EditorView8.theme({
2167
+ ".cm-tooltip": {
2168
+ background: "transparent"
2169
+ },
2170
+ ".cm-preview": {
2171
+ marginLeft: "-1rem",
2172
+ marginRight: "-1rem",
2173
+ padding: "1rem",
2174
+ borderRadius: "1rem",
2175
+ background: "var(--dx-modalSurface)",
2176
+ border: "1px solid var(--dx-separator)"
2177
+ }
2039
2178
  })
2040
2179
  ];
2041
2180
  };
2042
2181
 
2043
2182
  // packages/ui/react-ui-editor/src/extensions/comments.ts
2044
2183
  import { invertedEffects } from "@codemirror/commands";
2045
- import { StateEffect as StateEffect3, StateField as StateField4 } from "@codemirror/state";
2046
- import { hoverTooltip, keymap as keymap5, Decoration as Decoration4, EditorView as EditorView9, ViewPlugin as ViewPlugin4 } from "@codemirror/view";
2184
+ import { StateEffect as StateEffect3, StateField as StateField5 } from "@codemirror/state";
2185
+ import { hoverTooltip, keymap as keymap5, Decoration as Decoration5, EditorView as EditorView10, ViewPlugin as ViewPlugin5 } from "@codemirror/view";
2047
2186
  import sortBy from "lodash.sortby";
2048
2187
  import { useEffect, useMemo as useMemo2 } from "react";
2049
2188
  import { debounce as debounce2 } from "@dxos/async";
@@ -2052,7 +2191,7 @@ import { isNonNullable } from "@dxos/util";
2052
2191
 
2053
2192
  // packages/ui/react-ui-editor/src/extensions/selection.ts
2054
2193
  import { Transaction } from "@codemirror/state";
2055
- import { EditorView as EditorView8, keymap as keymap4 } from "@codemirror/view";
2194
+ import { EditorView as EditorView9, keymap as keymap4 } from "@codemirror/view";
2056
2195
  import { debounce } from "@dxos/async";
2057
2196
  import { invariant as invariant3 } from "@dxos/invariant";
2058
2197
  import { isNotFalsy as isNotFalsy2 } from "@dxos/util";
@@ -2063,7 +2202,7 @@ var createEditorStateTransaction = ({ scrollTo, selection }) => {
2063
2202
  return {
2064
2203
  selection,
2065
2204
  scrollIntoView: !scrollTo,
2066
- effects: scrollTo ? EditorView8.scrollIntoView(scrollTo, {
2205
+ effects: scrollTo ? EditorView9.scrollIntoView(scrollTo, {
2067
2206
  yMargin: 96
2068
2207
  }) : void 0,
2069
2208
  annotations: Transaction.userEvent.of(stateRestoreAnnotation)
@@ -2105,7 +2244,7 @@ var selectionState = ({ getState, setState } = {}) => {
2105
2244
  // setStateDebounced(id, {});
2106
2245
  // },
2107
2246
  // }),
2108
- EditorView8.updateListener.of(({ view, transactions }) => {
2247
+ EditorView9.updateListener.of(({ view, transactions }) => {
2109
2248
  const id = view.state.facet(documentId);
2110
2249
  if (!id || transactions.some((tr) => tr.isUserEvent(stateRestoreAnnotation))) {
2111
2250
  return;
@@ -2148,7 +2287,7 @@ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src
2148
2287
  var setComments = StateEffect3.define();
2149
2288
  var setSelection = StateEffect3.define();
2150
2289
  var setCommentState = StateEffect3.define();
2151
- var commentsState = StateField4.define({
2290
+ var commentsState = StateField5.define({
2152
2291
  create: (state) => ({
2153
2292
  id: state.facet(documentId),
2154
2293
  comments: [],
@@ -2186,7 +2325,7 @@ var commentsState = StateField4.define({
2186
2325
  return value;
2187
2326
  }
2188
2327
  });
2189
- var styles3 = EditorView9.theme({
2328
+ var styles3 = EditorView10.theme({
2190
2329
  ".cm-comment, .cm-comment-current": {
2191
2330
  margin: "0 -3px",
2192
2331
  padding: "3px",
@@ -2199,14 +2338,14 @@ var styles3 = EditorView9.theme({
2199
2338
  textDecoration: "underline"
2200
2339
  }
2201
2340
  });
2202
- var createCommentMark = (id, isCurrent) => Decoration4.mark({
2341
+ var createCommentMark = (id, isCurrent) => Decoration5.mark({
2203
2342
  class: isCurrent ? "cm-comment-current" : "cm-comment",
2204
2343
  attributes: {
2205
2344
  "data-testid": "cm-comment",
2206
2345
  "data-comment-id": id
2207
2346
  }
2208
2347
  });
2209
- var commentsDecorations = EditorView9.decorations.compute([
2348
+ var commentsDecorations = EditorView10.decorations.compute([
2210
2349
  commentsState
2211
2350
  ], (state) => {
2212
2351
  const { selection: { current }, comments: comments2 } = state.field(commentsState);
@@ -2226,10 +2365,10 @@ var commentsDecorations = EditorView9.decorations.compute([
2226
2365
  const mark = createCommentMark(comment.comment.id, comment.comment.id === current);
2227
2366
  return mark.range(range.from, range.to);
2228
2367
  }).filter(isNonNullable);
2229
- return Decoration4.set(decorations);
2368
+ return Decoration5.set(decorations);
2230
2369
  });
2231
2370
  var commentClickedEffect = StateEffect3.define();
2232
- var handleCommentClick = EditorView9.domEventHandlers({
2371
+ var handleCommentClick = EditorView10.domEventHandlers({
2233
2372
  click: (event, view) => {
2234
2373
  let target = event.target;
2235
2374
  const editorRoot = view.dom;
@@ -2268,7 +2407,7 @@ var trackPastedComments = (onUpdate) => {
2268
2407
  }
2269
2408
  };
2270
2409
  return [
2271
- EditorView9.domEventHandlers({
2410
+ EditorView10.domEventHandlers({
2272
2411
  cut: handleTrack,
2273
2412
  copy: handleTrack
2274
2413
  }),
@@ -2290,7 +2429,7 @@ var trackPastedComments = (onUpdate) => {
2290
2429
  return effects;
2291
2430
  }),
2292
2431
  // Handle paste or the undo of comment deletion.
2293
- EditorView9.updateListener.of((update2) => {
2432
+ EditorView10.updateListener.of((update2) => {
2294
2433
  const restore = [];
2295
2434
  for (let i = 0; i < update2.transactions.length; i++) {
2296
2435
  const tr = update2.transactions[i];
@@ -2430,7 +2569,7 @@ var comments = (options = {}) => {
2430
2569
  //
2431
2570
  // Track deleted ranges and update ranges for decorations.
2432
2571
  //
2433
- EditorView9.updateListener.of(({ view, state, changes }) => {
2572
+ EditorView10.updateListener.of(({ view, state, changes }) => {
2434
2573
  let mod = false;
2435
2574
  const { comments: comments2, ...value } = state.field(commentsState);
2436
2575
  changes.iterChanges((from, to, from2, to2) => {
@@ -2462,7 +2601,7 @@ var comments = (options = {}) => {
2462
2601
  //
2463
2602
  // Track selection/proximity.
2464
2603
  //
2465
- EditorView9.updateListener.of(({ view, state }) => {
2604
+ EditorView10.updateListener.of(({ view, state }) => {
2466
2605
  let min = Infinity;
2467
2606
  const { selection: { current, closest }, comments: comments2 } = state.field(commentsState);
2468
2607
  const { head } = state.selection.main;
@@ -2516,7 +2655,7 @@ var scrollThreadIntoView = (view, id, center = true) => {
2516
2655
  anchor: range.from
2517
2656
  } : void 0,
2518
2657
  effects: [
2519
- needsScroll ? EditorView9.scrollIntoView(range.from, center ? {
2658
+ needsScroll ? EditorView10.scrollIntoView(range.from, center ? {
2520
2659
  y: "center"
2521
2660
  } : void 0) : [],
2522
2661
  needsSelectionUpdate ? setSelection.of({
@@ -2562,13 +2701,13 @@ var ExternalCommentSync = class {
2562
2701
  this.unsubscribe = subscribe(updateComments);
2563
2702
  }
2564
2703
  };
2565
- var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin4.fromClass(class {
2704
+ var createExternalCommentSync = (id, subscribe, getComments) => ViewPlugin5.fromClass(class {
2566
2705
  constructor(view) {
2567
2706
  return new ExternalCommentSync(view, id, subscribe, getComments);
2568
2707
  }
2569
2708
  });
2570
2709
  var useCommentState = (state) => {
2571
- return useMemo2(() => EditorView9.updateListener.of((update2) => {
2710
+ return useMemo2(() => EditorView10.updateListener.of((update2) => {
2572
2711
  if (update2.docChanged || update2.selectionSet) {
2573
2712
  state.comment = selectionOverlapsComment(update2.state);
2574
2713
  state.selection = hasActiveSelection(update2.state);
@@ -2592,7 +2731,7 @@ var useComments = (view, id, comments2) => {
2592
2731
  });
2593
2732
  };
2594
2733
  var useCommentClickListener = (onCommentClick) => {
2595
- return useMemo2(() => EditorView9.updateListener.of((update2) => {
2734
+ return useMemo2(() => EditorView10.updateListener.of((update2) => {
2596
2735
  update2.transactions.forEach((transaction) => {
2597
2736
  transaction.effects.forEach((effect) => {
2598
2737
  if (effect.is(commentClickedEffect)) {
@@ -2606,21 +2745,21 @@ var useCommentClickListener = (onCommentClick) => {
2606
2745
  };
2607
2746
 
2608
2747
  // packages/ui/react-ui-editor/src/extensions/debug.ts
2609
- import { syntaxTree } from "@codemirror/language";
2610
- import { StateField as StateField5 } from "@codemirror/state";
2748
+ import { syntaxTree as syntaxTree2 } from "@codemirror/language";
2749
+ import { StateField as StateField6 } from "@codemirror/state";
2611
2750
  var debugNodeLogger = (log8 = console.log) => {
2612
- const logTokens = (state) => syntaxTree(state).iterate({
2751
+ const logTokens = (state) => syntaxTree2(state).iterate({
2613
2752
  enter: (node) => log8(node.type)
2614
2753
  });
2615
- return StateField5.define({
2754
+ return StateField6.define({
2616
2755
  create: (state) => logTokens(state),
2617
2756
  update: (_, tr) => logTokens(tr.state)
2618
2757
  });
2619
2758
  };
2620
2759
 
2621
2760
  // packages/ui/react-ui-editor/src/extensions/dnd.ts
2622
- import { dropCursor, EditorView as EditorView10 } from "@codemirror/view";
2623
- var styles4 = EditorView10.theme({
2761
+ import { dropCursor, EditorView as EditorView11 } from "@codemirror/view";
2762
+ var styles4 = EditorView11.theme({
2624
2763
  ".cm-dropCursor": {
2625
2764
  borderLeft: "2px solid var(--dx-accentText)",
2626
2765
  color: "var(--dx-accentText)",
@@ -2634,7 +2773,7 @@ var dropFile = (options = {}) => {
2634
2773
  return [
2635
2774
  styles4,
2636
2775
  dropCursor(),
2637
- EditorView10.domEventHandlers({
2776
+ EditorView11.domEventHandlers({
2638
2777
  drop: (event, view) => {
2639
2778
  event.preventDefault();
2640
2779
  const files = event.dataTransfer?.files;
@@ -2661,7 +2800,7 @@ import { bracketMatching, defaultHighlightStyle, syntaxHighlighting } from "@cod
2661
2800
  import { searchKeymap } from "@codemirror/search";
2662
2801
  import { EditorState } from "@codemirror/state";
2663
2802
  import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
2664
- import { EditorView as EditorView12, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap6, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
2803
+ import { EditorView as EditorView13, drawSelection, dropCursor as dropCursor2, highlightActiveLine, keymap as keymap6, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
2665
2804
  import defaultsDeep2 from "lodash.defaultsdeep";
2666
2805
  import merge from "lodash.merge";
2667
2806
  import { generateName } from "@dxos/display-name";
@@ -2669,10 +2808,10 @@ import { log as log5 } from "@dxos/log";
2669
2808
  import { hexToHue, isNotFalsy as isNotFalsy3 } from "@dxos/util";
2670
2809
 
2671
2810
  // packages/ui/react-ui-editor/src/extensions/focus.ts
2672
- import { StateEffect as StateEffect4, StateField as StateField6 } from "@codemirror/state";
2673
- import { EditorView as EditorView11 } from "@codemirror/view";
2811
+ import { StateEffect as StateEffect4, StateField as StateField7 } from "@codemirror/state";
2812
+ import { EditorView as EditorView12 } from "@codemirror/view";
2674
2813
  var focusEffect = StateEffect4.define();
2675
- var focusField = StateField6.define({
2814
+ var focusField = StateField7.define({
2676
2815
  create: () => false,
2677
2816
  update: (value, tr) => {
2678
2817
  for (const effect of tr.effects) {
@@ -2685,7 +2824,7 @@ var focusField = StateField6.define({
2685
2824
  });
2686
2825
  var focus = [
2687
2826
  focusField,
2688
- EditorView11.domEventHandlers({
2827
+ EditorView12.domEventHandlers({
2689
2828
  focus: (event, view) => {
2690
2829
  setTimeout(() => view.dispatch({
2691
2830
  effects: focusEffect.of(true)
@@ -2707,7 +2846,6 @@ var defaultBasicOptions = {
2707
2846
  bracketMatching: true,
2708
2847
  closeBrackets: true,
2709
2848
  drawSelection: true,
2710
- editable: true,
2711
2849
  focus: true,
2712
2850
  history: true,
2713
2851
  keymap: "standard",
@@ -2724,10 +2862,10 @@ var createBasicExtensions = (_props) => {
2724
2862
  const props = defaultsDeep2({}, _props, defaultBasicOptions);
2725
2863
  return [
2726
2864
  // NOTE: Doesn't catch errors in keymap functions.
2727
- EditorView12.exceptionSink.of((err) => {
2865
+ EditorView13.exceptionSink.of((err) => {
2728
2866
  log5.catch(err, void 0, {
2729
2867
  F: __dxlog_file8,
2730
- L: 97,
2868
+ L: 96,
2731
2869
  S: void 0,
2732
2870
  C: (f, a) => f(...a)
2733
2871
  });
@@ -2739,16 +2877,14 @@ var createBasicExtensions = (_props) => {
2739
2877
  props.drawSelection && drawSelection({
2740
2878
  cursorBlinkRate: 1200
2741
2879
  }),
2880
+ props.editable !== void 0 && EditorView13.editable.of(props.editable),
2742
2881
  props.focus && focus,
2743
2882
  props.highlightActiveLine && highlightActiveLine(),
2744
2883
  props.history && history(),
2745
2884
  props.lineNumbers && lineNumbers(),
2746
- props.lineWrapping && EditorView12.lineWrapping,
2885
+ props.lineWrapping && EditorView13.lineWrapping,
2747
2886
  props.placeholder && placeholder(props.placeholder),
2748
- props.readonly && [
2749
- EditorState.readOnly.of(true),
2750
- EditorView12.editable.of(false)
2751
- ],
2887
+ props.readOnly !== void 0 && EditorState.readOnly.of(props.readOnly),
2752
2888
  props.scrollPastEnd && scrollPastEnd(),
2753
2889
  props.tabSize && EditorState.tabSize.of(props.tabSize),
2754
2890
  // https://codemirror.net/docs/ref/#view.KeyBinding
@@ -2783,14 +2919,14 @@ var defaultThemeSlots = {
2783
2919
  var createThemeExtensions = ({ themeMode, styles: styles5, syntaxHighlighting: _syntaxHighlighting, slots: _slots } = {}) => {
2784
2920
  const slots = defaultsDeep2({}, _slots, defaultThemeSlots);
2785
2921
  return [
2786
- EditorView12.darkTheme.of(themeMode === "dark"),
2787
- EditorView12.baseTheme(styles5 ? merge({}, defaultTheme, styles5) : defaultTheme),
2922
+ EditorView13.darkTheme.of(themeMode === "dark"),
2923
+ EditorView13.baseTheme(styles5 ? merge({}, defaultTheme, styles5) : defaultTheme),
2788
2924
  // https://github.com/codemirror/theme-one-dark
2789
2925
  _syntaxHighlighting && (themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle)),
2790
- slots.editor?.className && EditorView12.editorAttributes.of({
2926
+ slots.editor?.className && EditorView13.editorAttributes.of({
2791
2927
  class: slots.editor.className
2792
2928
  }),
2793
- slots.content?.className && EditorView12.contentAttributes.of({
2929
+ slots.content?.className && EditorView13.contentAttributes.of({
2794
2930
  class: slots.content.className
2795
2931
  })
2796
2932
  ].filter(isNotFalsy3);
@@ -2819,7 +2955,7 @@ var createDataExtensions = ({ id, text, space, identity }) => {
2819
2955
 
2820
2956
  // packages/ui/react-ui-editor/src/extensions/folding.tsx
2821
2957
  import { codeFolding, foldGutter } from "@codemirror/language";
2822
- import { EditorView as EditorView13 } from "@codemirror/view";
2958
+ import { EditorView as EditorView14 } from "@codemirror/view";
2823
2959
  import React3 from "react";
2824
2960
  import { Icon } from "@dxos/react-ui";
2825
2961
  var folding = (_props = {}) => [
@@ -2843,7 +2979,7 @@ var folding = (_props = {}) => [
2843
2979
  }));
2844
2980
  }
2845
2981
  }),
2846
- EditorView13.theme({
2982
+ EditorView14.theme({
2847
2983
  ".cm-foldGutter": {
2848
2984
  opacity: 0.3,
2849
2985
  transition: "opacity 0.3s",
@@ -2856,14 +2992,14 @@ var folding = (_props = {}) => [
2856
2992
  ];
2857
2993
 
2858
2994
  // packages/ui/react-ui-editor/src/extensions/listener.ts
2859
- import { EditorView as EditorView14 } from "@codemirror/view";
2995
+ import { EditorView as EditorView15 } from "@codemirror/view";
2860
2996
  var listener = ({ onFocus, onChange }) => {
2861
2997
  const extensions = [];
2862
- onFocus && extensions.push(EditorView14.focusChangeEffect.of((_, focusing) => {
2998
+ onFocus && extensions.push(EditorView15.focusChangeEffect.of((_, focusing) => {
2863
2999
  onFocus(focusing);
2864
3000
  return null;
2865
3001
  }));
2866
- onChange && extensions.push(EditorView14.updateListener.of((update2) => {
3002
+ onChange && extensions.push(EditorView15.updateListener.of((update2) => {
2867
3003
  onChange(update2.state.doc.toString(), update2.state.facet(documentId));
2868
3004
  }));
2869
3005
  return extensions;
@@ -2871,9 +3007,9 @@ var listener = ({ onFocus, onChange }) => {
2871
3007
 
2872
3008
  // packages/ui/react-ui-editor/src/extensions/markdown/formatting.ts
2873
3009
  import { snippet } from "@codemirror/autocomplete";
2874
- import { syntaxTree as syntaxTree2 } from "@codemirror/language";
3010
+ import { syntaxTree as syntaxTree3 } from "@codemirror/language";
2875
3011
  import { EditorSelection } from "@codemirror/state";
2876
- import { EditorView as EditorView15, keymap as keymap7 } from "@codemirror/view";
3012
+ import { EditorView as EditorView16, keymap as keymap7 } from "@codemirror/view";
2877
3013
  import { useMemo as useMemo3 } from "react";
2878
3014
  var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
2879
3015
  var Inline;
@@ -2896,7 +3032,7 @@ var setHeading = (level) => {
2896
3032
  let prevBlock = -1;
2897
3033
  for (const range of ranges) {
2898
3034
  let sawBlock = false;
2899
- syntaxTree2(state).iterate({
3035
+ syntaxTree3(state).iterate({
2900
3036
  from: range.from,
2901
3037
  to: range.to,
2902
3038
  enter: (node) => {
@@ -3005,7 +3141,7 @@ var setStyle = (type, enable) => {
3005
3141
  let startCovered = false;
3006
3142
  let endCovered = false;
3007
3143
  let { from, to } = range;
3008
- syntaxTree2(state).iterate({
3144
+ syntaxTree3(state).iterate({
3009
3145
  from,
3010
3146
  to,
3011
3147
  enter: (node) => {
@@ -3208,7 +3344,7 @@ var insertTable = (view) => {
3208
3344
  snippets.table(view, null, from, from);
3209
3345
  };
3210
3346
  var removeLinkInner = (from, to, changes, state) => {
3211
- syntaxTree2(state).iterate({
3347
+ syntaxTree3(state).iterate({
3212
3348
  from,
3213
3349
  to,
3214
3350
  enter: (node) => {
@@ -3253,7 +3389,7 @@ var addLink = ({ url, image: image2 } = {}) => {
3253
3389
  let { from, to } = range;
3254
3390
  const cutStyles = [];
3255
3391
  let okay = null;
3256
- syntaxTree2(state).iterate({
3392
+ syntaxTree3(state).iterate({
3257
3393
  from,
3258
3394
  to,
3259
3395
  enter: (node) => {
@@ -3348,7 +3484,7 @@ var addList = (type) => {
3348
3484
  let parentColumn = null;
3349
3485
  const blocks = [];
3350
3486
  for (const { from, to } of state.selection.ranges) {
3351
- syntaxTree2(state).iterate({
3487
+ syntaxTree3(state).iterate({
3352
3488
  from,
3353
3489
  to,
3354
3490
  enter: (node) => {
@@ -3483,7 +3619,7 @@ var removeList = (type) => {
3483
3619
  const stack = [];
3484
3620
  const targetNodeType = type === 0 ? "OrderedList" : type === 1 ? "BulletList" : "TaskList";
3485
3621
  for (const { from, to } of state.selection.ranges) {
3486
- syntaxTree2(state).iterate({
3622
+ syntaxTree3(state).iterate({
3487
3623
  from,
3488
3624
  to,
3489
3625
  enter: (node) => {
@@ -3570,7 +3706,7 @@ var setBlockquote = (enable) => {
3570
3706
  let lastBlock = -1;
3571
3707
  for (const { from, to } of state.selection.ranges) {
3572
3708
  const sawBlock = false;
3573
- syntaxTree2(state).iterate({
3709
+ syntaxTree3(state).iterate({
3574
3710
  from,
3575
3711
  to,
3576
3712
  enter: (node) => {
@@ -3660,7 +3796,7 @@ var addCodeblock = (target) => {
3660
3796
  for (const { from, to } of selection.ranges) {
3661
3797
  let blockFrom = from;
3662
3798
  let blockTo = to;
3663
- syntaxTree2(state).iterate({
3799
+ syntaxTree3(state).iterate({
3664
3800
  from,
3665
3801
  to,
3666
3802
  enter: (node) => {
@@ -3711,7 +3847,7 @@ var removeCodeblock = ({ state, dispatch }) => {
3711
3847
  let lastBlock = -1;
3712
3848
  const changes = [];
3713
3849
  for (const { from, to } of state.selection.ranges) {
3714
- syntaxTree2(state).iterate({
3850
+ syntaxTree3(state).iterate({
3715
3851
  from,
3716
3852
  to,
3717
3853
  enter: (node) => {
@@ -3873,7 +4009,7 @@ var getFormatting = (state) => {
3873
4009
  }
3874
4010
  }
3875
4011
  }
3876
- syntaxTree2(state).iterate({
4012
+ syntaxTree3(state).iterate({
3877
4013
  from: range.from,
3878
4014
  to: range.to,
3879
4015
  enter: (node) => {
@@ -3962,7 +4098,7 @@ var getFormatting = (state) => {
3962
4098
  };
3963
4099
  };
3964
4100
  var useFormattingState = (state) => {
3965
- return useMemo3(() => EditorView15.updateListener.of((update2) => {
4101
+ return useMemo3(() => EditorView16.updateListener.of((update2) => {
3966
4102
  if (update2.docChanged || update2.selectionSet) {
3967
4103
  Object.entries(getFormatting(update2.state)).forEach(([key, active]) => {
3968
4104
  state[key] = active;
@@ -4245,9 +4381,9 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
4245
4381
  };
4246
4382
 
4247
4383
  // packages/ui/react-ui-editor/src/extensions/markdown/debug.ts
4248
- import { syntaxTree as syntaxTree3 } from "@codemirror/language";
4249
- import { StateField as StateField7 } from "@codemirror/state";
4250
- var debugTree = (cb) => StateField7.define({
4384
+ import { syntaxTree as syntaxTree4 } from "@codemirror/language";
4385
+ import { StateField as StateField8 } from "@codemirror/state";
4386
+ var debugTree = (cb) => StateField8.define({
4251
4387
  create: (state) => cb(convertTreeToJson(state)),
4252
4388
  update: (value, tr) => cb(convertTreeToJson(tr.state))
4253
4389
  });
@@ -4268,24 +4404,24 @@ var convertTreeToJson = (state) => {
4268
4404
  }
4269
4405
  return node;
4270
4406
  };
4271
- return treeToJson(syntaxTree3(state).cursor());
4407
+ return treeToJson(syntaxTree4(state).cursor());
4272
4408
  };
4273
4409
 
4274
4410
  // packages/ui/react-ui-editor/src/extensions/markdown/decorate.ts
4275
- import { syntaxTree as syntaxTree7 } from "@codemirror/language";
4276
- import { RangeSetBuilder as RangeSetBuilder3, StateEffect as StateEffect5 } from "@codemirror/state";
4277
- import { EditorView as EditorView19, Decoration as Decoration7, WidgetType as WidgetType5, ViewPlugin as ViewPlugin6 } from "@codemirror/view";
4411
+ import { syntaxTree as syntaxTree8 } from "@codemirror/language";
4412
+ import { RangeSetBuilder as RangeSetBuilder4, StateEffect as StateEffect5 } from "@codemirror/state";
4413
+ import { EditorView as EditorView20, Decoration as Decoration8, WidgetType as WidgetType6, ViewPlugin as ViewPlugin7 } from "@codemirror/view";
4278
4414
  import { invariant as invariant4 } from "@dxos/invariant";
4279
4415
  import { mx as mx4 } from "@dxos/react-ui-theme";
4280
4416
 
4281
4417
  // packages/ui/react-ui-editor/src/extensions/markdown/changes.ts
4282
- import { syntaxTree as syntaxTree4 } from "@codemirror/language";
4418
+ import { syntaxTree as syntaxTree5 } from "@codemirror/language";
4283
4419
  import { Transaction as Transaction2 } from "@codemirror/state";
4284
- import { ViewPlugin as ViewPlugin5 } from "@codemirror/view";
4420
+ import { ViewPlugin as ViewPlugin6 } from "@codemirror/view";
4285
4421
  var adjustChanges = () => {
4286
- return ViewPlugin5.fromClass(class {
4422
+ return ViewPlugin6.fromClass(class {
4287
4423
  update(update2) {
4288
- const tree = syntaxTree4(update2.state);
4424
+ const tree = syntaxTree5(update2.state);
4289
4425
  const adjustments = [];
4290
4426
  for (const tr of update2.transactions) {
4291
4427
  const event = tr.annotation(Transaction2.userEvent);
@@ -4423,14 +4559,14 @@ var getValidUrl = (str) => {
4423
4559
  };
4424
4560
 
4425
4561
  // packages/ui/react-ui-editor/src/extensions/markdown/image.ts
4426
- import { syntaxTree as syntaxTree5 } from "@codemirror/language";
4427
- import { StateField as StateField8 } from "@codemirror/state";
4428
- import { Decoration as Decoration5, EditorView as EditorView16, WidgetType as WidgetType3 } from "@codemirror/view";
4562
+ import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4563
+ import { StateField as StateField9 } from "@codemirror/state";
4564
+ import { Decoration as Decoration6, EditorView as EditorView17, WidgetType as WidgetType4 } from "@codemirror/view";
4429
4565
  var image = (_options = {}) => {
4430
4566
  return [
4431
- StateField8.define({
4567
+ StateField9.define({
4432
4568
  create: (state) => {
4433
- return Decoration5.set(buildDecorations(0, state.doc.length, state));
4569
+ return Decoration6.set(buildDecorations2(0, state.doc.length, state));
4434
4570
  },
4435
4571
  update: (value, tr) => {
4436
4572
  if (!tr.docChanged && !tr.selection) {
@@ -4450,10 +4586,10 @@ var image = (_options = {}) => {
4450
4586
  filterFrom: from,
4451
4587
  filterTo: to,
4452
4588
  filter: () => false,
4453
- add: buildDecorations(from, to, tr.state)
4589
+ add: buildDecorations2(from, to, tr.state)
4454
4590
  });
4455
4591
  },
4456
- provide: (field) => EditorView16.decorations.from(field)
4592
+ provide: (field) => EditorView17.decorations.from(field)
4457
4593
  })
4458
4594
  ];
4459
4595
  };
@@ -4465,10 +4601,10 @@ var preloadImage = (url) => {
4465
4601
  preloaded.add(url);
4466
4602
  }
4467
4603
  };
4468
- var buildDecorations = (from, to, state) => {
4604
+ var buildDecorations2 = (from, to, state) => {
4469
4605
  const decorations = [];
4470
4606
  const cursor = state.selection.main.head;
4471
- syntaxTree5(state).iterate({
4607
+ syntaxTree6(state).iterate({
4472
4608
  enter: (node) => {
4473
4609
  if (node.name === "Image") {
4474
4610
  const urlNode = node.node.getChild("URL");
@@ -4479,7 +4615,7 @@ var buildDecorations = (from, to, state) => {
4479
4615
  return;
4480
4616
  }
4481
4617
  preloadImage(url);
4482
- decorations.push(Decoration5.replace({
4618
+ decorations.push(Decoration6.replace({
4483
4619
  block: true,
4484
4620
  widget: new ImageWidget(url)
4485
4621
  }).range(hide2 ? node.from : node.to, node.to));
@@ -4491,7 +4627,7 @@ var buildDecorations = (from, to, state) => {
4491
4627
  });
4492
4628
  return decorations;
4493
4629
  };
4494
- var ImageWidget = class extends WidgetType3 {
4630
+ var ImageWidget = class extends WidgetType4 {
4495
4631
  constructor(_url) {
4496
4632
  super();
4497
4633
  this._url = _url;
@@ -4513,10 +4649,10 @@ var ImageWidget = class extends WidgetType3 {
4513
4649
  };
4514
4650
 
4515
4651
  // packages/ui/react-ui-editor/src/extensions/markdown/styles.ts
4516
- import { EditorView as EditorView17 } from "@codemirror/view";
4652
+ import { EditorView as EditorView18 } from "@codemirror/view";
4517
4653
  var bulletListIndentationWidth = 24;
4518
4654
  var orderedListIndentationWidth = 36;
4519
- var formattingStyles = EditorView17.theme({
4655
+ var formattingStyles = EditorView18.theme({
4520
4656
  /**
4521
4657
  * Horizontal rule.
4522
4658
  */
@@ -4635,18 +4771,18 @@ var formattingStyles = EditorView17.theme({
4635
4771
  });
4636
4772
 
4637
4773
  // packages/ui/react-ui-editor/src/extensions/markdown/table.ts
4638
- import { syntaxTree as syntaxTree6 } from "@codemirror/language";
4639
- import { RangeSetBuilder as RangeSetBuilder2, StateField as StateField9 } from "@codemirror/state";
4640
- import { Decoration as Decoration6, EditorView as EditorView18, WidgetType as WidgetType4 } from "@codemirror/view";
4774
+ import { syntaxTree as syntaxTree7 } from "@codemirror/language";
4775
+ import { RangeSetBuilder as RangeSetBuilder3, StateField as StateField10 } from "@codemirror/state";
4776
+ import { Decoration as Decoration7, EditorView as EditorView19, WidgetType as WidgetType5 } from "@codemirror/view";
4641
4777
  var table = (options = {}) => {
4642
- return StateField9.define({
4778
+ return StateField10.define({
4643
4779
  create: (state) => update(state, options),
4644
4780
  update: (_, tr) => update(tr.state, options),
4645
- provide: (field) => EditorView18.decorations.from(field)
4781
+ provide: (field) => EditorView19.decorations.from(field)
4646
4782
  });
4647
4783
  };
4648
4784
  var update = (state, _options) => {
4649
- const builder = new RangeSetBuilder2();
4785
+ const builder = new RangeSetBuilder3();
4650
4786
  const cursor = state.selection.main.head;
4651
4787
  const tables = [];
4652
4788
  const getTable = () => tables[tables.length - 1];
@@ -4654,7 +4790,7 @@ var update = (state, _options) => {
4654
4790
  const table2 = getTable();
4655
4791
  return table2.rows?.[table2.rows.length - 1];
4656
4792
  };
4657
- syntaxTree6(state).iterate({
4793
+ syntaxTree7(state).iterate({
4658
4794
  enter: (node) => {
4659
4795
  switch (node.name) {
4660
4796
  case "Table": {
@@ -4687,19 +4823,19 @@ var update = (state, _options) => {
4687
4823
  tables.forEach((table2) => {
4688
4824
  const replace = state.readOnly || cursor < table2.from || cursor > table2.to;
4689
4825
  if (replace) {
4690
- builder.add(table2.from, table2.to, Decoration6.replace({
4826
+ builder.add(table2.from, table2.to, Decoration7.replace({
4691
4827
  block: true,
4692
4828
  widget: new TableWidget(table2)
4693
4829
  }));
4694
4830
  } else {
4695
- builder.add(table2.from, table2.to, Decoration6.mark({
4831
+ builder.add(table2.from, table2.to, Decoration7.mark({
4696
4832
  class: "cm-table"
4697
4833
  }));
4698
4834
  }
4699
4835
  });
4700
4836
  return builder.finish();
4701
4837
  };
4702
- var TableWidget = class extends WidgetType4 {
4838
+ var TableWidget = class extends WidgetType5 {
4703
4839
  constructor(_table) {
4704
4840
  super();
4705
4841
  this._table = _table;
@@ -4741,14 +4877,14 @@ var Unicode = {
4741
4877
  bulletSmall: "\u2219",
4742
4878
  bulletSquare: "\u2B1D"
4743
4879
  };
4744
- var HorizontalRuleWidget = class extends WidgetType5 {
4880
+ var HorizontalRuleWidget = class extends WidgetType6 {
4745
4881
  toDOM() {
4746
4882
  const el = document.createElement("span");
4747
4883
  el.className = "cm-hr";
4748
4884
  return el;
4749
4885
  }
4750
4886
  };
4751
- var LinkButton = class extends WidgetType5 {
4887
+ var LinkButton = class extends WidgetType6 {
4752
4888
  constructor(url, render) {
4753
4889
  super();
4754
4890
  this.url = url;
@@ -4764,7 +4900,7 @@ var LinkButton = class extends WidgetType5 {
4764
4900
  return el;
4765
4901
  }
4766
4902
  };
4767
- var CheckboxWidget = class extends WidgetType5 {
4903
+ var CheckboxWidget = class extends WidgetType6 {
4768
4904
  constructor(_checked) {
4769
4905
  super();
4770
4906
  this._checked = _checked;
@@ -4809,7 +4945,7 @@ var CheckboxWidget = class extends WidgetType5 {
4809
4945
  return false;
4810
4946
  }
4811
4947
  };
4812
- var TextWidget = class extends WidgetType5 {
4948
+ var TextWidget = class extends WidgetType6 {
4813
4949
  constructor(text, className) {
4814
4950
  super();
4815
4951
  this.text = text;
@@ -4824,29 +4960,29 @@ var TextWidget = class extends WidgetType5 {
4824
4960
  return el;
4825
4961
  }
4826
4962
  };
4827
- var hide = Decoration7.replace({});
4828
- var blockQuote = Decoration7.line({
4963
+ var hide = Decoration8.replace({});
4964
+ var blockQuote = Decoration8.line({
4829
4965
  class: mx4("cm-blockquote")
4830
4966
  });
4831
- var fencedCodeLine = Decoration7.line({
4967
+ var fencedCodeLine = Decoration8.line({
4832
4968
  class: mx4("cm-code cm-codeblock-line")
4833
4969
  });
4834
- var fencedCodeLineFirst = Decoration7.line({
4970
+ var fencedCodeLineFirst = Decoration8.line({
4835
4971
  class: mx4("cm-code cm-codeblock-line", "cm-codeblock-first")
4836
4972
  });
4837
- var fencedCodeLineLast = Decoration7.line({
4973
+ var fencedCodeLineLast = Decoration8.line({
4838
4974
  class: mx4("cm-code cm-codeblock-line", "cm-codeblock-last")
4839
4975
  });
4840
4976
  var commentBlockLine = fencedCodeLine;
4841
4977
  var commentBlockLineFirst = fencedCodeLineFirst;
4842
4978
  var commentBlockLineLast = fencedCodeLineLast;
4843
- var horizontalRule = Decoration7.replace({
4979
+ var horizontalRule = Decoration8.replace({
4844
4980
  widget: new HorizontalRuleWidget()
4845
4981
  });
4846
- var checkedTask = Decoration7.replace({
4982
+ var checkedTask = Decoration8.replace({
4847
4983
  widget: new CheckboxWidget(true)
4848
4984
  });
4849
- var uncheckedTask = Decoration7.replace({
4985
+ var uncheckedTask = Decoration8.replace({
4850
4986
  widget: new CheckboxWidget(false)
4851
4987
  });
4852
4988
  var editingRange = (state, range, focus2) => {
@@ -4861,9 +4997,9 @@ var autoHideTags = /* @__PURE__ */ new Set([
4861
4997
  "SubscriptMark",
4862
4998
  "SuperscriptMark"
4863
4999
  ]);
4864
- var buildDecorations2 = (view, options, focus2) => {
4865
- const deco = new RangeSetBuilder3();
4866
- const atomicDeco = new RangeSetBuilder3();
5000
+ var buildDecorations3 = (view, options, focus2) => {
5001
+ const deco = new RangeSetBuilder4();
5002
+ const atomicDeco = new RangeSetBuilder4();
4867
5003
  const { state } = view;
4868
5004
  const headerLevels = [];
4869
5005
  const getHeaderLevels = (node, level) => {
@@ -4950,7 +5086,7 @@ var buildDecorations2 = (view, options, focus2) => {
4950
5086
  } else {
4951
5087
  const num = headers.slice(from - 1).map((level2) => level2?.number ?? 0).join(".") + " ";
4952
5088
  if (num.length) {
4953
- atomicDeco.add(mark.from, mark.from + len, Decoration7.replace({
5089
+ atomicDeco.add(mark.from, mark.from + len, Decoration8.replace({
4954
5090
  widget: new TextWidget(num, theme.heading(level))
4955
5091
  }));
4956
5092
  }
@@ -4975,7 +5111,7 @@ var buildDecorations2 = (view, options, focus2) => {
4975
5111
  if (node.from === line.to - 1) {
4976
5112
  return false;
4977
5113
  }
4978
- deco.add(line.from, line.from, Decoration7.line({
5114
+ deco.add(line.from, line.from, Decoration8.line({
4979
5115
  class: "cm-list-item",
4980
5116
  attributes: {
4981
5117
  style: `padding-left: ${offset}px; text-indent: -${width}px;`
@@ -4992,7 +5128,7 @@ var buildDecorations2 = (view, options, focus2) => {
4992
5128
  const label = list.type === "OrderedList" ? `${++list.number}.` : Unicode.bulletSmall;
4993
5129
  const line = state.doc.lineAt(node.from);
4994
5130
  const to = state.doc.sliceString(node.to, node.to + 1) === " " ? node.to + 1 : node.to;
4995
- atomicDeco.add(line.from, to, Decoration7.replace({
5131
+ atomicDeco.add(line.from, to, Decoration8.replace({
4996
5132
  widget: new TextWidget(label, list.type === "OrderedList" ? "cm-list-mark cm-list-mark-ordered" : "cm-list-mark cm-list-mark-bullet")
4997
5133
  }));
4998
5134
  break;
@@ -5079,7 +5215,7 @@ var buildDecorations2 = (view, options, focus2) => {
5079
5215
  if (!editing) {
5080
5216
  atomicDeco.add(node.from, marks[0].to, hide);
5081
5217
  }
5082
- deco.add(marks[0].to, marks[1].from, Decoration7.mark({
5218
+ deco.add(marks[0].to, marks[1].from, Decoration8.mark({
5083
5219
  tagName: "a",
5084
5220
  attributes: {
5085
5221
  class: "cm-link",
@@ -5089,7 +5225,7 @@ var buildDecorations2 = (view, options, focus2) => {
5089
5225
  }
5090
5226
  }));
5091
5227
  if (!editing) {
5092
- atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration7.replace({
5228
+ atomicDeco.add(marks[1].from, node.to, options.renderLinkButton ? Decoration8.replace({
5093
5229
  widget: new LinkButton(url, options.renderLinkButton)
5094
5230
  }) : hide);
5095
5231
  }
@@ -5123,7 +5259,7 @@ var buildDecorations2 = (view, options, focus2) => {
5123
5259
  }
5124
5260
  }
5125
5261
  };
5126
- const tree = syntaxTree7(state);
5262
+ const tree = syntaxTree8(state);
5127
5263
  if (options.numberedHeadings?.from === void 0) {
5128
5264
  for (const { from, to } of view.visibleRanges) {
5129
5265
  tree.iterate({
@@ -5147,13 +5283,13 @@ var buildDecorations2 = (view, options, focus2) => {
5147
5283
  var forceUpdate = StateEffect5.define();
5148
5284
  var decorateMarkdown = (options = {}) => {
5149
5285
  return [
5150
- ViewPlugin6.fromClass(class {
5286
+ ViewPlugin7.fromClass(class {
5151
5287
  constructor(view) {
5152
- ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(view, options, view.hasFocus));
5288
+ ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations3(view, options, view.hasFocus));
5153
5289
  }
5154
5290
  update(update2) {
5155
5291
  if (update2.docChanged || update2.viewportChanged || update2.focusChanged || update2.transactions.some((tr) => tr.effects.some((effect) => effect.is(forceUpdate))) || update2.selectionSet && !options.selectionChangeDelay) {
5156
- ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations2(update2.view, options, update2.view.hasFocus));
5292
+ ({ deco: this.deco, atomicDeco: this.atomicDeco } = buildDecorations3(update2.view, options, update2.view.hasFocus));
5157
5293
  this.clearUpdate();
5158
5294
  } else if (update2.selectionSet) {
5159
5295
  this.scheduleUpdate(update2.view);
@@ -5179,9 +5315,9 @@ var decorateMarkdown = (options = {}) => {
5179
5315
  }
5180
5316
  }, {
5181
5317
  provide: (plugin) => [
5182
- EditorView19.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
5183
- EditorView19.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration7.none),
5184
- EditorView19.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration7.none)
5318
+ EditorView20.atomicRanges.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
5319
+ EditorView20.decorations.of((view) => view.plugin(plugin)?.atomicDeco ?? Decoration8.none),
5320
+ EditorView20.decorations.of((view) => view.plugin(plugin)?.deco ?? Decoration8.none)
5185
5321
  ]
5186
5322
  }),
5187
5323
  image(),
@@ -5192,12 +5328,12 @@ var decorateMarkdown = (options = {}) => {
5192
5328
  };
5193
5329
 
5194
5330
  // packages/ui/react-ui-editor/src/extensions/markdown/link.ts
5195
- import { syntaxTree as syntaxTree8 } from "@codemirror/language";
5331
+ import { syntaxTree as syntaxTree9 } from "@codemirror/language";
5196
5332
  import { hoverTooltip as hoverTooltip2 } from "@codemirror/view";
5197
5333
  import { tooltipContent } from "@dxos/react-ui-theme";
5198
5334
  var linkTooltip = (render) => {
5199
5335
  return hoverTooltip2((view, pos, side) => {
5200
- const syntax = syntaxTree8(view.state).resolveInner(pos, side);
5336
+ const syntax = syntaxTree9(view.state).resolveInner(pos, side);
5201
5337
  let link = null;
5202
5338
  for (let i = 0, node = syntax; !link && node && i < 5; node = node.parent, i++) {
5203
5339
  link = node.name === "Link" ? node : null;
@@ -5378,7 +5514,7 @@ var useActionHandler = (view) => {
5378
5514
 
5379
5515
  // packages/ui/react-ui-editor/src/hooks/useTextEditor.ts
5380
5516
  import { EditorState as EditorState2 } from "@codemirror/state";
5381
- import { EditorView as EditorView20 } from "@codemirror/view";
5517
+ import { EditorView as EditorView21 } from "@codemirror/view";
5382
5518
  import { useFocusableGroup } from "@fluentui/react-tabster";
5383
5519
  import { useCallback as useCallback3, useEffect as useEffect2, useMemo as useMemo4, useRef, useState } from "react";
5384
5520
  import { log as log7 } from "@dxos/log";
@@ -5422,7 +5558,7 @@ var useTextEditor = (props = {}, deps = []) => {
5422
5558
  id && documentId.of(id),
5423
5559
  extensions,
5424
5560
  // NOTE: This doesn't catch errors in keymap functions.
5425
- EditorView20.exceptionSink.of((err) => {
5561
+ EditorView21.exceptionSink.of((err) => {
5426
5562
  log7.catch(err, void 0, {
5427
5563
  F: __dxlog_file11,
5428
5564
  L: 97,
@@ -5432,10 +5568,10 @@ var useTextEditor = (props = {}, deps = []) => {
5432
5568
  })
5433
5569
  ].filter(isNotFalsy4)
5434
5570
  });
5435
- view2 = new EditorView20({
5571
+ view2 = new EditorView21({
5436
5572
  parent: parentRef.current,
5437
5573
  state,
5438
- scrollTo: scrollTo ? EditorView20.scrollIntoView(scrollTo, {
5574
+ scrollTo: scrollTo ? EditorView21.scrollIntoView(scrollTo, {
5439
5575
  yMargin: 96
5440
5576
  }) : void 0,
5441
5577
  dispatchTransactions: debug ? debugDispatcher : void 0
@@ -5534,7 +5670,7 @@ export {
5534
5670
  EditorInputModes,
5535
5671
  EditorState3 as EditorState,
5536
5672
  EditorToolbar,
5537
- EditorView21 as EditorView,
5673
+ EditorView22 as EditorView,
5538
5674
  EditorViewMode,
5539
5675
  EditorViewModes,
5540
5676
  Inline,
@@ -5620,7 +5756,7 @@ export {
5620
5756
  setStyle,
5621
5757
  singleValueFacet,
5622
5758
  stackItemContentEditorClassNames,
5623
- stackItemContentToolbarClassNames,
5759
+ stackItemContentToolbarClassNames2 as stackItemContentToolbarClassNames,
5624
5760
  table,
5625
5761
  tags2 as tags,
5626
5762
  textRange,